package main

import (
	"fmt"
	"github.com/labstack/gommon/log"
	"time"
)

func main() {
	c := make(chan int)
	for i := -10; i < 10; i = i + 2 {

		go func(i int) {
			defer RecoverGoPanic()
			time.Sleep(time.Second * 1)
			fmt.Println(10 / i)
			c <- i
		}(i)
	}

	go func() {
		for {
			fmt.Println(<-c)
		}
	}()

	time.Sleep(time.Second * 100)
	fmt.Println("main exit")
}

func RecoverGoPanic() {
	if err := recover(); err != nil {
		log.Error(err)
	}
}
